<template>
    <div class="legendary-order" v-loading="loading">
        <div class="table-box">
            <el-table :data="tableData" ref="table" border style="width: 100%">
                <el-table-column min-width="120" label="日期" prop="ymd">
                    <template slot-scope="scope">
                        <div>{{ tableFormatDate(scope.row.ymd) }}</div>
                    </template>
                </el-table-column>
                <el-table-column min-width="80" label="接单数" prop="total"></el-table-column>
                <el-table-column min-width="120" label="王者25-50星">
                    <template slot-scope="scope">
                        <div :class="[scope.row.maxJobLevel >= 17 ? 'max-level' : '']">{{ scope.row.wangFive || 0 }}</div>
                    </template>
                </el-table-column>
                <el-table-column min-width="120" label="王者0-25星">
                    <template slot-scope="scope">
                        <div :class="[scope.row.maxJobLevel >= 16 ? 'max-level' : '']">{{ scope.row.wangTwo || 0 }}</div>
                    </template>
                </el-table-column>
                <el-table-column min-width="80" label="星耀">
                    <template slot-scope="scope">
                        <div :class="[scope.row.maxJobLevel >= 15 ? 'max-level' : '']">{{ scope.row.xin || 0 }}</div>
                    </template>
                </el-table-column>
                <el-table-column min-width="80" label="钻石">
                    <template slot-scope="scope">
                        <div :class="[scope.row.maxJobLevel >= 14 ? 'max-level' : '']">{{ scope.row.zhuan || 0 }}</div>
                    </template>
                </el-table-column>
                <el-table-column min-width="80" label="铂金">
                    <template slot-scope="scope">
                        <div :class="[scope.row.maxJobLevel >= 13 ? 'max-level' : '']">{{ scope.row.bo || 0 }}</div>
                    </template>
                </el-table-column>
                <el-table-column min-width="80" label="黄金">
                    <template slot-scope="scope">
                        <div :class="[scope.row.maxJobLevel >= 12 ? 'max-level' : '']">{{ scope.row.huang || 0 }}</div>
                    </template>
                </el-table-column>
                <el-table-column min-width="80" label="白银">
                    <template slot-scope="scope">
                        <div :class="[scope.row.maxJobLevel >= 11 ? 'max-level' : '']">{{ scope.row.bai || 0 }}</div>
                    </template>
                </el-table-column>
                <el-table-column min-width="80" label="青铜">
                    <template slot-scope="scope">
                        <div :class="[scope.row.maxJobLevel >= 10 ? 'max-level' : '']">{{ scope.row.qing || 0 }}</div>
                    </template>
                </el-table-column>
            </el-table>
        </div>
        <div class="tools">
            <el-pagination
                @size-change="sizeChange"
                @current-change="pageChange"
                :current-page="pageNum"
                :page-sizes="_pageSizes"
                :page-size="pageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="total">
            </el-pagination>
        </div>
    </div>
</template>

<script>
import { formatDate } from '@/utils/utils'

export default {
    name: 'legendaryOrder',
    props: {
        tabIndex: ''
    },
    data () {
        return {
            pageNum: 1,
            pageSize: this._pageSize,
            tableData: [],
            total: 0,
            loading: false
        }
    },
    watch: {
        tabIndex (value) {
            if (value === '7') {
                this.getList(1)
            }
        }
    },
    methods: {
        // 获取列表
        async getList (pageNum) {
            if (this.loading) return
            this.pageNum = pageNum
            this.loading = true
            let params = {
                pageNum,
                pageSize: this.pageSize,
                userId: this.$route.query.userId
            }
            let res = await this.$http.get('/team/selectTeamKingOrderDetail', { params })
            if (res.code === '0') {
                this.tableData = res.data
            } else {
                this.$message({
                    type: 'error',
                    message: '系统异常，请稍后再试'
                })
            }
            this.loading = false
        },
        // 页码切换
        sizeChange (val) {
            this.pageNum = 1
            this.pageSize = val
            this.getList(1)
        },
        // 页容切换
        pageChange (val) {
            this.pageNum = val
            this.getList(this.pageNum)
        },
        tableFormatDate (time) {
            return formatDate(time, 'YYYY-MM-DD HH:MM:SS')
        }
    }
}
</script>

<style lang="scss" scoped>
    .legendary-order {
        .input-box {
            margin-top: 10px;
            font-size: 13px;
            font-weight: 500;
            .input-title {
                margin: 0 10px 0 20px;
            }
            .btn {
                margin-top: 10px;
                margin-left: 10px;
            }
        }

        .table-box {
            margin: 20px 0;
            .cover {
                width: 80px;
                height: 80px;
                > img {
                    width: 100%;
                    height: 100%;
                }
            }
            .user-icon {
                width: 20px;
                height: 20px;
                border-radius: 50%;
                margin-right: 5px;
                vertical-align: top;
            }
            .table-btn {
                cursor: pointer;
                color: #409EFF;
                font-size: 13px;
                font-weight: 500;
                &:hover {
                    text-decoration: underline;
                }
            }
            .max-level {
                color: #00BF3C;
            }
        }
    }
    .tools {
        padding-right: 20px;
        display: flex;
        justify-content: flex-end;
    }
</style>
